%{
#include <stdio.h>    
#include <stdlib.h>    
    int yylex();
%}

%left '+'
%left '-'
%right '*'
%right '/'

%%

lines: line
    | line  lines
;

line: exp  '\n'
    | exp
;

exp: n
    | exp '+' exp
    | exp '-' exp
    | exp '*' exp
    | exp '/' exp
    | '(' exp ')'
;

n: '1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'0'
%%

void yyerror(char *s)
{
    printf(stderr, "\s\n", s);
    return;
}

int yylex()
{
    return getchar();
}

int main(int argc, char **args)
{
    yyparse();
    return 0;
}